package com.sjk.flink.functions;

import com.sjk.flink.correct.IfCorrectRule;
import com.sjk.flink.correct.rules.UnifyDateTimeRuler;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TestAB {
    public static void main(String[] args) throws Exception{
        int expireTime = 24;
        String dataField_ts ="2024-04-16 12:51:31";
        String compareField_ts= "2024-05-28 11:22:18.709";
        //数据时间单独校准
        IfCorrectRule crrectRule = new UnifyDateTimeRuler();
        dataField_ts = (String) crrectRule.transformValue(dataField_ts);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date parse = dateFormat.parse(dataField_ts);
        long dataTs = parse.getTime();
        Date compareparse = dateFormat.parse(compareField_ts);
        long compareTs = compareparse.getTime();
        double cha = compareTs - dataTs;
        double result = cha * 1.0 / (1000 * 60 * 60);
        System.out.println(">>>>>>>>>>>>>>  "+result);
        if (result > 0 && result <= expireTime) {
            //未过期数据
            System.out.println(">>>>>>>>>>>>>>>>> "+true);
        } else {
            //过期数据
            System.out.println(">>>>>>>>>>>>>>>>> "+false);
        }
    }
}
